/*
 * Created: 2022-08-26 21:20:26
 * Author : 涛涛涛
 */

import React, { FC } from 'react';
import { View, Text } from '@tarojs/components';
import { styled } from 'linaria/react';
import { useClassName } from '@/utils/index';
import { HomeContext, useLayoutHeights } from './RootPageComponentContext';
import MyScrollBody from './MyScrollBody/MyScrollBody';
import MyHeadNav from './MyHeadNav/MyHeadNav';
export interface IProps extends ICompProps {
    /** 是否允许导航展开 */
    enableExpand?: boolean;
    /** 顶部导航左侧显示 logo:点击去主页 arrow:点击返回上一页 */
    headNavLeftShow?: 'logo' | 'arrow';
    /** 顶部导航栏右侧的功能插槽 */
    headNavContentRightSlot?: React.ReactNode;
    /** 左边logo标题 */
    leftTitle?: string;
    /** 底部留白(单位px) */
    scrollOffsetBottom?: number;
    /** 头部固定Slot的插槽位 */
    headFixedSlot?: React.ReactNode;
    /** 中间核心主要区域 */
    children?: React.ReactElement | React.ReactElement[] | ((renderProps: { height: number }) => React.ReactElement);
}
RootPageComponent.defaultProps = {
    headNavLeftShow: 'logo',
    enableExpand: false,
    leftTitle: '',
    scrollOffsetBottom: 40,
} as Partial<IProps>;
function RootPageComponent(props: IProps) {
    const { className, style, children } = props;
    const localClassName = useClassName('RootPageComponent', className);
    const layoutHeight = useLayoutHeights(props);
    return (
        <HomeContext.Provider value={{ ...layoutHeight, ...props }}>
            <RootView className={localClassName} style={style}>
                <MyHeadNav></MyHeadNav>
                <MyScrollBody>{children}</MyScrollBody>
            </RootView>
        </HomeContext.Provider>
    );
}
export default React.memo(RootPageComponent as FC<IProps>);
const RootView = styled(View)`
    &.RootPageComponent {
    }
`;
